<?php
App::import('Controller','Config.BaseConfig');
class MapConfigController extends BaseConfigController
{
	var $name = 'MapConfig';
	var $configModelAlias = "MapConfig";
	function admin_setting()
	{
		$this->MapConfig->setFieldOptions();
		parent::admin_setting("Map");
		$this->render("/site_config/admin_setting");
	}
	
	function admin_icons()
	{
		$this->pageTitle = __("Map Config");
		$MapIconModel = cri("MapIcon");
		$iconsList = $MapIconModel->getIconsList();
		$categroiesList = cri("ListCategory")->getOptions();
		if($this->data)
		{
			$icon = $this->data['MapIcon']['icon'];
			if($icon)
			{
				foreach($this->data['MapIcon']['category'] as $categoryId => $checked)
				{
					if($checked == false)
					{
						continue;
					}
					$data = array();
					$data['MapIcon'] = array("icon"=>$icon,'category_id'=>$categoryId);
					$MapIconModel->create();
					$id = null;
					$id = $MapIconModel->field("id",array('category_id'=>$categoryId));
					if($id)
					{
						$MapIconModel->id = $id;
					}
					$MapIconModel->save($data);
				}
				$this->successMsg(__("Icon information has been saved."));
			}else
			{
				$this->errorMsg(__("Please select a icon."));
			}
		}
		$this->data = array();
		$categoryIcons = $MapIconModel->getCategoryIcons(true);
		$this->set(compact('categroiesList','iconsList','categoryIcons'));
	}
}
?>